export function parse(n: number) {
    let allCount = 0;
    for(let i = 0, len = n; i <= len; i++) {
        allCount = allCount + get1(i);
    }
    return allCount;
}

function get1(n: number) {
    let count = 0;
    const strN = n.toString();
    strN.split('').forEach(value => {
        if (value === '1') {
            count++
        }
    });
    return count;
}

function lottery(arr: number[],n: number){
    if (arr.length <= n) {
        return arr;
    };
    const luckP: number[] = [];
    for(let i = 0; i < n; i++) {
        let len = arr.length;
        const index = Math.random() * len;
        luckP.push(arr[index]);
        arr.splice(index, 1);
    }
    return luckP;
}